package com.ruyuan.eshop.manager.controller.trade;

import com.ruyuan.eshop.framework.core.WebPage;
import com.ruyuan.eshop.common.domain.entity.OrderComplainDO;
import com.ruyuan.eshop.common.domain.request.ComplainQueryParam;
import com.ruyuan.eshop.common.domain.vo.OrderComplainDOVO;
import com.ruyuan.eshop.common.service.trade.OrderComplainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 交易投诉表控制器
 *
 * @author pwd
 * @version 1.0
 */
@RestController
@RequestMapping("/admin/v1.0/trade/order-complains")
@Api(description = "交易投诉表相关API")
public class OrderComplainManagerController {

    @Autowired
    private OrderComplainService orderComplainService;

    /**
     * 查询交易投诉表列表
     * @param pageNo
     * @param pageSize
     * @param param
     * @return
     */
    @ApiOperation(value = "查询交易投诉表列表")
    @GetMapping
    public WebPage list(Long pageNo, Long pageSize, ComplainQueryParam param) {
        param.setPageNo(pageNo);
        param.setPageSize(pageSize);
        return this.orderComplainService.list(param);
    }

    /**
     * 审核并交由商家申诉
     * @param id
     * @return
     */
    @PutMapping(value = "/{id}/to-appeal")
    @ApiOperation(value = "审核并交由商家申诉")
    public OrderComplainDO auth(@PathVariable Long id) {
        return this.orderComplainService.auth(id);
    }

    /**
     * 查询一个交易投诉
     * @param id
     * @return
     */
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "查询一个交易投诉")
    public OrderComplainDOVO get(@PathVariable Long id) {
        return this.orderComplainService.getModelAndCommunication(id);
    }

}
